import 'package:flutter/material.dart';
import 'package:whale/helper/component/base/tabbar/config.dart';

import '../../../../helper/component/base/tabbar/index.dart';
import '../../../../helper/utils/util.dart';
import 'index.dart';

class TabbarDemoPage extends GetView<TabbarDemoController> with TabBarMixin {
  const TabbarDemoPage({Key? key}) : super(key: key);

  // 主视图
  Widget _buildView() {
    final state = controller.state;
    return SeparatorColumn(
      children: [
        indicatorTabBar(
          controller: state.lineCtrl,
          titles: state.titles,
        ),
        indicatorTabBar(
          controller: state.indicatorCtrl,
          titles: state.titles,
          config: TabbarConfig.line(
            indicatorImg: 'line.png'.imgPathCommon,
          ),
        ),
        indicatorTabBar(
          controller: state.indicatorCtrl,
          titles: state.titles,
          config: TabbarConfig.line(
            indicatorImg: 'foot.png'.imgPathCommon,
            indicatorAlign: Alignment.center,
          ),
        ),
        bgTabBar(
          controller: state.indicatorCtrl,
          titles: state.titles,
          config: TabbarConfig.bg(),
        ),
      ],
      separatorBuilder: (index) => SizedBox(height: 10.r),
    );
  }

  @override
  Widget build(BuildContext context) {
    return GetBuilder<TabbarDemoController>(
      builder: (_) {
        return Scaffold(
          appBar: AppBar(title: const Text("分段控制器TabBar")),
          body: SafeArea(
            child: _buildView(),
          ),
        );
      },
    );
  }
}
